 
package com.zdkj.subway.check.controller.subwayRat.excelimportexport;

import com.zdkj.common.core.exceltools.MultipartFileToFile;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.check.entity.SwAuTvmSingleAssist;
import com.zdkj.subway.check.service.SwSwAuExcelImportAndExportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.File;


/**
 * 收入审核Excel导入和导出入口类
 *
 * @author 
 * @date 2020-12-10 10:55:09
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/check/excel" )
@Api(value = "swauexcel", tags = "收入审核-涉及到模版的导入导出")
public class SwAuExcelImportAndExportController {

    private final SwSwAuExcelImportAndExportService swSwAuExcelImportAndExportService;

    /**
     * TVM单台设备协查导入（SC）
     * @param file
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "TVM单台设备协查导入（SC）", notes = "TVM单台设备协查导入（SC）")
    @SysLog("TVM单台设备协查导入（SC）")
    @PostMapping({ "/sc/tvm/singletvmassist/import" })
    public R saveScTvmSingleAssistBatch(@RequestParam("file") final MultipartFile file) throws Exception {
        //MultipartFile 转 File
        final File excelFile = MultipartFileToFile.multipartFileToFile(file);
        //TVM单台设备SC层级的导入
        return R.ok((Object)this.swSwAuExcelImportAndExportService.importScTvmSingleAssistBatch(excelFile));
    }
    /**
     * TVM单台设备协查导出（SC）
     * @param
     * @return
     * @throws
     */
    @ApiOperation(value = "TVM单台设备协查导出（SC）", notes = "TVM单台设备协查导出（SC）")
    @GetMapping("/sc/tvm/singletvmassist/export")
    public void exportScSingletvmassist(String ids, SwAuTvmSingleAssist params,HttpServletResponse response) {
        swSwAuExcelImportAndExportService.exportScSingleTvmAssist(ids,params,response);
    }
}
